package com.shushan.mixedexam.oralcalculation.bean;

import com.android.net.bean.NetBaseBean;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * @ClassName: OralCalculateExerciseBean
 * @Desciption: //口算练习习题数据bean
 * @author: zhangshihao
 * @date: 2018-07-26
 */
public class OralCalculateExerciseBean extends NetBaseBean {

    public int id;
    public String questions;
    public String answer;
    public int outline_detail_id;
    public int outline_id;
    public String my_answer_id;
    public int type;//口算练习类型：0--普通口算；1--分式口算
    public int fz1,fm1,fz2,fm2;//分子分母
    public String ys1;//运算符
    public int fz,fm;//答案分子分母

    public String my_answer;//用户答案 练习记录详情接口：无
    public int result;//是否正确 练习记录详情接口：无

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        if(jsonObject == null){
            return;
        }
        id = jsonObject.optInt("id",0);
        type = jsonObject.optInt("type",0);
        questions = jsonObject.optString("questions", "");
        answer = jsonObject.optString("answer","");
        if(type == 1) {
            JSONObject fenshuObj = new JSONObject(questions);
            fz1 = fenshuObj.optInt("fz1",0);
            fm1 = fenshuObj.optInt("fm1",0);
            fz2 = fenshuObj.optInt("fz2",0);
            fm2 = fenshuObj.optInt("fm2",0);
            ys1 = fenshuObj.optString("ys1","");
            JSONObject answerObj = new JSONObject(answer);
            fz = answerObj.optInt("fz",0);
            fm = answerObj.optInt("fm",0);
        }
        outline_id = jsonObject.optInt("outline_id",0);
        outline_detail_id = jsonObject.optInt("outline_detail_id",0);
        my_answer_id = jsonObject.optString("my_answer_id","");

        my_answer = jsonObject.optString("my_answer","");
        result = jsonObject.optInt("result",0);
    }
}
